<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>员工列表</title>
<%
	pageContext.setAttribute("APP_PATH", request.getContextPath());
%>
<!-- web路径：
不以/开始的相对路径，找资源，以当前资源的路径为基准，经常容易出问题。
以/开始的相对路径，找资源，以服务器的路径为标准(http://localhost:3306)；需要加上项目名
		http://localhost:3306/crud
 -->
<script type="text/javascript"
	src="${APP_PATH }/static/js/jquery-1.12.4.min.js"></script>
<link
	href="${APP_PATH }/static/bootstrap-3.3.7-dist/css/bootstrap.min.css"
	rel="stylesheet">
<script
	src="${APP_PATH }/static/bootstrap-3.3.7-dist/js/bootstrap.min.js"></script>
<style>  
.col-center-block {  
  margin-top: 100px;
    float: none;  
    display: block;  
    margin-left: auto;  
    margin-right: auto; 
    
}  
</style>  
</head>
<body>
	<!-- 搭建显示页面 -->
	<div class="container">
	
	
	
		<div class="well col-md-10 col-center-block" id="login">  
				<h3>凌展账号</h3>
			    <div class="input-group input-group-md">  
			          <span class="input-group-addon" id="sizing-addon1"><i class="glyphicon glyphicon-user" aria-hidden="true"></i></span>  
			          <input type="text" id="userID" class="form-control" placeholder="学号" aria-describedby="sizing-addon1">  
			    </div>  
			    <div class="input-group input-group-md">  
			          <span class="input-group-addon" id="sizing-addon1"><i class="glyphicon glyphicon-lock"></i></span>  
			          <input type="password" id="pass" class="form-control" placeholder="密码" aria-describedby="sizing-addon1">  
			    </div>
			    <br>
			    <button id="submit" class="btn btn-success btn-block">登录 </button>  
		</div>  
		
	
	
	
		<div id="score">
			<!-- 标题 -->
			<div class="row">
				<div class="col-md-12">
					<h1>${sessionScope.user}同学你好</h1>
					<h2>你的成绩如下:</h2>
				</div>
			</div>
			<!-- 显示表格数据 -->
			<div class="row">
				<div class="col-md-12">
					<table class="table table-striped table-bordered" id="emps_table">
						<thead>
							<tr>
								<!-- <th>学年</th> -->
								<th style="width: 200px" class="success">课程</th>
								<th style="width: 60px"  class="success">学分</th>
								<th style="width: 60px"  class="success">成绩</th>
								<th style="width: 60px"  class="danger">状态</th>
							</tr>
						</thead>
						<tbody>
					
						</tbody>
					</table>
				</div>
			</div>
		</div>
		
		
	</div>
	<script type="text/javascript">
	
		$(document).ready(function(){
			$("#score").hide()
			
			 $("#submit").click(function(){
				 var userID=$("#userID").val();
				 var pass=$("#pass").val();
				 
					$.ajax({
						url:"${APP_PATH}/user/login",
						type:"POST",
						data: "username=" + userID + "&password=" + pass,
						success:function(data){
							if(data.length>0){
								 $("#login").hide()
								 $("#score").show()
							}
							var $tr;
							for(var i=0 ; i<data.length; i++){
								var $table = $("#emps_table");
								for(var j=0 ; j<data[i].上学期.length ; j++){
									$tr='<tr>';
									//$tr+='<td>'+data[i].学年+'</td>';
									$tr+='<td>'+data[i].上学期[j].course+'</td>';
									$tr+='<td>'+data[i].上学期[j].credit+'</td>';
									$tr+='<td> '+data[i].上学期[j].score+' </td>';
									$tr+='<td> '+data[i].上学期[j].state+' </td>';
									$tr+='</tr>'
									$table.append($tr);
								}
								for(var j=0 ; j<data[i].下学期.length ; j++){
									$tr='<tr>';
									//$tr+='<td>'+data[i].学年+'</td>';
									$tr+='<td>'+data[i].下学期[j].course+'</td>';
									$tr+='<td>'+data[i].下学期[j].credit+'</td>';
									$tr+='<td>'+data[i].下学期[j].score+'</td>';
									$tr+='<td>'+data[i].下学期[j].state+'</td>';
									$tr+='</tr>'
									$table.append($tr);
								}
							}
						}
					});
				 
			 });
			 
		});
	</script>
</body>
</html>